Code written in python3
Readme written in notepad++
Created by Robert Hannan (emerson) April 17, 2020


Thanks to loopy for asm6
Thanks to Pokun for the fds assembly code


=====REVISIONS=====
Rev3 (July 2, 2020):	fixed a bug where a subroutine label ending in a valid vector label would be compiled
						as the vector if it appeared before the actual vector label
						for example, a subroutine labelled "DisableNMI:" would be interpreted as the nmi vector
						if it appeared before "NMI:"

Rev2 (April 19, 2020):	fixed byte encoding bug
						prints current rev when quiet mode is disabled

Rev1 (April 17, 2020):	initial release



=====WHAT IS FDS_VECTOR_CALC=====

As the name implies 'fds_vector_calc' is used to calculate the vector addresses
	when compiling a famicom disk image (.fds). It uses the .lst file generated by
	asm6 to get the addresses and outputs them in a 10-byte binary file. The binary
	file can then be placed excactly at PRAM address $dff6.



=====FDS_VECTOR_CALC.EXE ARGUMENTS=====

From the command prompt, call:
	
	fds_vector_calc [-q] [-qe] (InputFile.lst) (OutputFile.bin)
	
	
where:

	-q, -quiet			= display only warning and error messages during runtime
	
	-qe. -quiet_error	= disable all messages during runtime
	
	(InputFile.lst)		= The .lst file generated by asm6
		
	(OutputFile.bin)	= Whatever you want your vector filename to be.
						  Be sure the filename matches what is in your
						  main block assignment code.


examples:
	
	fds_vector_calc homebrew.lst vectors.bin		;this will display all messages during runtime
	fds_vector_calc -q homebrew.lst vectors.bin		;this will display only warnings and errors during runtime
	fds_vector_calc -qe homebrew.lst vectors.bin	;this disables all messages during runtime
	
	
	
=====INPUT FILE REQUIREMENTS=====

The two valid vector label usages are:

	NMI:
	RESET:
	IRQ:
	
or:
	
	NMI1:
	NMI2:
	NMI3:
	RESET:
	IRQ:
	
It is necessary that all vector labels are in the same file and end with a colon (:).
	Vector labels may appear in any order. 'fds_vector_calc' is not case sensitive, 
	so any combination of upper and lower case letters are valid. Any vector label
	that is commented out with a semicolon (ex.  ;NMI:)	will be omitted from the
	output file, but labels with a comment afterward (ex.   NMI:	;comment) are valid.
	
If only the 'NMI:' label is found, 'fds_vector_calc' will use its address to fill in the
	remaining two vector addresses automatically. Therefore, it is not necessary to state
	'NMI1:' 'NMI2:'	and 'NMI3:' if only one non-maskable interrupt is needed.
	
It is necessary to put '.base $xxxx' at the start of the input file .asm code. For example,
	if the input file is to be placed at PRAM address $6000, then put '.base $6000' at the
	start of the code.

example:

	.base $6000		;FDS Program RAM (PRAM) start address
	
	RESET:
		lda #$c0
		sta $0100	;set NMI
		lda #$80
		sta $0101	;set IRQ
		lda #$35
		sta $0102	;disk game reset
		lda #$53	
		sta $0103
	
	

=====HOW TO USE FDS_VECTOR_CALC.EXE WITH ASM6 TO CREATE A DISK IMAGE=====

- First use asm6 with the '-l' argument and compile the .asm code containing the vector labels.
  This will generate both a binary of your code along with a .lst file with the necessary addresses.
- Next call 'fds_vector_calc' with the appropriate arguments and files.
- Use asm6 to compile all other necessary files. The '-l' argument is not necessary.
- Finally, compile the main block assignment code with asm6 to generate the .fds disk image.



The example batch file below compiles 'homebrew.asm' and generates both 'homebrew.bin' and 'homebrew.lst'
	and stores them in the 'inc\' directory. It then calls 'fds_vector_calc' and writes 'vectors.bin'
	to the 'inc\' directory. Finally, asm6 is called to compile the main block assignment code and
	generates the .fds disk image.

example batch file:
	
	@echo off
	asm6 -l homebrew.asm inc\homebrew.bin inc\homebrew.lst
	fds_vector_calc inc\homebrew.lst inc\vectors.bin
	asm6 my_fds_demo.asm my_fds_demo.fds
	pause
	break
	
	
	
example of vector binary file in main block assignment code:

	;File "VECTORS-"
	;File Header Block
		.db $03						;Block code, file header block
		.db $02						;File Number
		.db $02						;File ID
		.db "VECTORS-"				;File Name
		.dw $dff6					;Where to load file in PRAM
		.dw $000a					;File Size
		.db $00 					;File type
	;File Data Block
		.db $04						;Block code, file data block
		.incbin "inc\vectors.bin"	;This file contains the vector addresses.
		
	
	
	
	